///////////////////////////////////////////////////////////////////////////////
///// Assignment 3: CPU Scheduler
///// By: Brady Robichaud (robicb82) & Patrick Filtz (filtzp43)
///// Date: 4/19/2013
///// File: Node.java
///// Description: This class deals with creating the process node and 
/////	creating the queue/wait node.
/////	
///////////////////////////////////////////////////////////////////////////////
package round2;

public class Node {
	//Process p;
	Node nextNode = null;
	boolean waitNode;
	int waitTime;
	boolean isIO;
	
	int pID;
	int duration;
	int curRemTime;
	
	//Constructor for process node 
	public Node(int pid, int curRemTime, int duration, boolean isIO){
		pID = pid;
		this.curRemTime = curRemTime;
		this.duration = duration;
		this.isIO = isIO;
		nextNode = new Node(isIO);
		waitNode = false;
	}
	
	//Constructor for wait node 
	public Node(boolean isIO){
		waitNode = true;
		this.isIO = isIO;
		waitTime = 0;
		pID = -1;
	}

	//Used for printing queue to the terminal.  Prints to a string, used for debugging/testing only. 
	public String print(){
		String output = "";
		if(waitNode){
			output = String.format("|%" + -(5 + waitTime) + "s", ("Wait:" + waitTime));
		}else{
			if(isIO){
				output = String.format("|%" + -(3 + duration) + "s", ("P" + pID + ":" + duration));
			}else{
				output = String.format("|%" + -(3 + duration) + "s", ("P" + pID + ":" + duration));
			}
		}
		return output;
	}
}
